#include <iostream>
#include <memory>
#include <vector>
#include <thread>
#include "component.h"
#include "decorator.h"
#include "concretecomponent.h"
#include <mutex>
std::mutex g_mutex;
void performOperation(std::shared_ptr<Component> component){
    component->operation();
}
int main(int argc, char *argv[])
{
    const int numThreads = 10;
    std::vector<std::thread> threads;
    for(int i=0 ; i < numThreads ; ++i){
        threads.emplace_back([&](){
            std::shared_ptr<Component> component = std::make_shared<ConcreteComponent>();
            std::shared_ptr<Component> decoratedComponent = std::make_shared<Decorator>(component);
            if(decoratedComponent != nullptr){
               performOperation(decoratedComponent);
            }
        });
    }
    for (auto& thread:threads){
        thread.join();
    }
    return 0;
}
